﻿using System;
using System.Windows.Forms;
using Presentation;
using StatisticCalculatorApplication;


namespace WinFormsView
{
    public partial class MainForm : Form, IView
    {
        private readonly LogForm logBrowser;
        public MainForm()
        {
            InitializeComponent();
            logBrowser = new LogForm { Visible = false };
            var application = new StatsApplication();
            application.start(this);
        }
        public string SampleData
        {
            get
            {
                return SampleDataTextBox.Text;
            }
            set
            {
                SampleDataTextBox.Text = value;
            }
        }
        public string ErrorMessage
        {
            get
            {
                return errorMessageLabel.Text;
            }
            set
            {
                errorMessageLabel.Text = value;
            }
        }
        public string ExpectedValueUniformDistribution
        {
            get
            {
                return mathematicalExpectationLabel.Text;
            }
            set
            {
                mathematicalExpectationLabel.Text = value;
            }
        }

        public string VarianceUniformDistribution
        {
            get
            {
                return varianceLabel.Text;
            }
            set
            {
                varianceLabel.Text = value;
            }
        }
        public string SampleMean
        {
            get
            {
                return meanLabel.Text;
            }
            set
            {
                meanLabel.Text = value;
            }
        }
        public string SampleVariance
        {
            get
            {
                return varianceMomentsLabel.Text;
            }
            set
            {
                varianceMomentsLabel.Text = value;
            }
        }
       public string SampleSkewness
        {
            get
            {
                return sampleSkewnessLabel.Text;
            }
            set
            {
                sampleSkewnessLabel.Text = value;
            }
        }
        public string  SampleKurtosis
        {
            get
            {
                return sampleKurtosisLabel.Text;
            }
            set
            {
                sampleKurtosisLabel.Text = value;
            }
        }

        public string[] Logs
        {
            set { logBrowser.Logs = value; }
        }
        public Action OnInputData
        { set; private get; }
        public Action OnClearEntries
        { set; private get; }
        public Action OnProcessExpectedValueOfUniformDistribution
        { set; private get; }

        public Action OnProcessVarianceOfUniformDistribution
        { set; private get; }
        public Action OnProcessSampleMean
        { set; private get; }
        public Action OnProcessSampleVariance
        { set; private get; }

        public Action OnProcessSampleSkewness
        { set; private get; }
        public Action OnProcessSampleKurtosis
        { set; private get; }
        public Action OnShowLogs { set; private get; }

        private void calculateStatistics_Click(object sender, EventArgs e)
        {
            OnInputData();
            OnProcessExpectedValueOfUniformDistribution();
            OnProcessVarianceOfUniformDistribution();
            OnProcessSampleMean();
            OnProcessSampleVariance();
            OnProcessSampleSkewness();
            OnProcessSampleKurtosis();

        }

        private void clearEntries_Click(object sender, EventArgs e)
        {
            OnClearEntries();
        }

        private void SampleDataTextBox_Leave(object sender, EventArgs e)
        {
          //  OnInputData();
           // OnClearEntries();
        }

        private void ShowLogsForm_Click(object sender, EventArgs e)
        {
            OnShowLogs();
        }

    }
}
